﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class UnityUtil
{
    /// <summary>
    /// 得到子节点
    /// </summary>
    public static Transform GetChildBone(Transform self, string name)
    {
        Queue<Transform> searchQueue = new Queue<Transform>();
        searchQueue.Enqueue(self);
        while (searchQueue.Count > 0)
        {
            var trans = searchQueue.Dequeue();
            if (trans.gameObject.name.Equals(name))
            {
                return trans;
            }
            foreach (Transform childTrans in trans)
            {
                searchQueue.Enqueue(childTrans);
            }
        }
        return null;
    }
    /// <summary>
    /// 得到子节点
    /// </summary>
    public static void Destroy(Object obj)
    {
        GameObject.Destroy(obj);
    }
}
